package com.haohan.jingyuan.customer.helper;

import com.haohan.jingyuan.customer.dto.resp.TraceInfoResp;
import com.haohan.jingyuan.customer.entity.CustomerTrace;
import org.springframework.util.CollectionUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * 追踪响应对象转换辅助类
 * 
 * @ClassName TraceRespHelper
 * @Description 追踪信息响应对象转换辅助类
 * @Author hexijun
 * @Time 2025/01/19 15:00
 * @Version 1.0
 */
public class TraceRespHelper {

    /**
     * 将CustomerTrace实体转换为TraceInfoResp响应对象
     * 
     * @param customerTrace 追踪实体
     * @return 追踪响应对象
     */
    public static TraceInfoResp convert2TraceInfoResp(CustomerTrace customerTrace) {
        if (customerTrace == null) {
            return null;
        }

        TraceInfoResp resp = new TraceInfoResp();
        resp.setId(customerTrace.getId());
        resp.setTraceId(customerTrace.getTraceId());
        resp.setCustomerId(customerTrace.getCustomerId());
        resp.setContent(customerTrace.getContent());
        resp.setCreator(customerTrace.getCreator());
        resp.setGmtCreated(customerTrace.getGmtCreated());
        resp.setModifier(customerTrace.getModifier());
        resp.setGmtModified(customerTrace.getGmtModified());

        return resp;
    }

    /**
     * 将CustomerTrace实体列表转换为TraceInfoResp响应对象列表
     * 
     * @param customerTraceList 追踪实体列表
     * @return 追踪响应对象列表
     */
    public static List<TraceInfoResp> convert2TraceInfoRespList(List<CustomerTrace> customerTraceList) {
        if (CollectionUtils.isEmpty(customerTraceList)) {
            return new ArrayList<>();
        }

        List<TraceInfoResp> respList = new ArrayList<>();
        for (CustomerTrace customerTrace : customerTraceList) {
            respList.add(convert2TraceInfoResp(customerTrace));
        }

        return respList;
    }
}
